//
//  SAInventoryDetail2Cell.m
//  yidiantong
//
//  Created by 黄志刚 on 2020/11/6.
//

#import "SAInventoryDetail2Cell.h"
#import "SAInventoryListModel.h"
#import "UILabel+NSMutableAttributedString.h"

@interface SAInventoryDetail2Cell ()

@property (nonatomic, strong) UIView *line;
@property (nonatomic, strong) UILabel *shopNameLab;
@property (nonatomic, strong) UILabel *colourLab;
@property (nonatomic, strong) UILabel *sizeLab;
@property (nonatomic, strong) UILabel *inventoryLab;
@property (nonatomic, strong) UILabel *ceilingLimitLab;

@end


@implementation SAInventoryDetail2Cell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}
-(void)setModel:(SAInventoryListRecods *)model {
    _model = model;
    self.shopNameLab.text = [NSString stringWithFormat:@"%@\n%@",model.productCode,model.productName];
    [self.shopNameLab setAttributedStringWithSubString:model.productName color:kGrayColor];
    self.colourLab.text = model.colourName;
    self.sizeLab.text = model.sizeName;
    self.inventoryLab.text = model.stock;
    if ([model.stockUp integerValue] == 0 && [model.stockUp integerValue] == 0) {
        self.ceilingLimitLab.text = @"--";
    }else {
        self.ceilingLimitLab.text = [NSString stringWithFormat:@"%@-%@",model.stockDown,model.stockUp];
    }
}


#pragma mark - initUI
-(void)initUI {
    [self.contentView addSubview:self.line];
    [self.contentView addSubview:self.shopNameLab];
    [self.contentView addSubview:self.colourLab];
    [self.contentView addSubview:self.sizeLab];
    [self.contentView addSubview:self.inventoryLab];
    [self.contentView addSubview:self.ceilingLimitLab];
}

#pragma mark - lazy
-(UIView *)line {
    if (!_line) {
        _line = [[UIView alloc] initWithFrame:SARectMake(0, 39, kBaseScreenWidth, 1)];
        _line.backgroundColor = kLineColor;
    }
    return _line;
}

-(UILabel *)shopNameLab {
    if (!_shopNameLab) {
        _shopNameLab = [[UILabel alloc] initWithFrame:SARectMake(30, 0, 80, 39)];
        _shopNameLab.textColor = kBlackColor;
        _shopNameLab.textAlignment = NSTextAlignmentLeft;
        _shopNameLab.numberOfLines = 0;
        _shopNameLab.font = kFont(13);
        _shopNameLab.numberOfLines = 0;
    }
    return _shopNameLab;
}

-(UILabel *)colourLab {
    if (!_colourLab) {
        _colourLab = [[UILabel alloc] initWithFrame:SARectMake(110, 0, 60, 39)];
        _colourLab.textColor = kBlackColor;
        _colourLab.textAlignment = NSTextAlignmentCenter;
        _colourLab.numberOfLines = 0;
        _colourLab.font = kFont(13);
    }
    return _colourLab;
}

-(UILabel *)sizeLab {
    if (!_sizeLab) {
        _sizeLab = [[UILabel alloc] initWithFrame:SARectMake(170, 0, 60, 39)];
        _sizeLab.textColor = kBlackColor;
        _sizeLab.textAlignment = NSTextAlignmentCenter;
        _sizeLab.numberOfLines = 0;
        _sizeLab.font = kFont(13);
    }
    return _sizeLab;
}

-(UILabel *)inventoryLab {
    if (!_inventoryLab) {
        _inventoryLab = [[UILabel alloc] initWithFrame:SARectMake(230, 0, 60, 39)];
        _inventoryLab.textColor = kBlackColor;
        _inventoryLab.textAlignment = NSTextAlignmentCenter;
        _inventoryLab.numberOfLines = 0;
        _inventoryLab.font = kFont(13);
    }
    return _inventoryLab;
}

-(UILabel *)ceilingLimitLab {
    if (!_ceilingLimitLab) {
        _ceilingLimitLab = [[UILabel alloc] initWithFrame:SARectMake(290, 0, 80, 39)];
        _ceilingLimitLab.textColor = kBlackColor;
        _ceilingLimitLab.textAlignment = NSTextAlignmentCenter;
        _ceilingLimitLab.numberOfLines = 0;
        _ceilingLimitLab.font = kFont(13);
    }
    return _ceilingLimitLab;
}



@end

